<!--tvm票款差异协查-->
<template>
  <div class="zhanNeiRYDLCK approve el-card is-always-shadow el-card__body">
    <el-dialog
      title="申诉"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form v-if="isReload" class="shouPiaoYuanCYQRTZForm" :option="option" v-model="formData" @submit="handleSubmit">

        <template slot-scope="scope" slot="differenceAmount">
          <span>{{fenExYuangettoFixed(scope,'value')}}</span>
        </template>

        <template slot-scope="scope" slot="menuForm">
          <el-button type="primary" @click="handleSubmit(2)">保存</el-button>
          <el-button type="default" @click="closed">取消</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
import {
  fenExYuangettoFixed
} from "@/api/subwayRat/commonCheck";
import {updateSwAuTvmNotice} from '@/api/subwayRat/swAuTvm/tvmCYQRTZ'

export default {
  components:{
  },
  data() {
    return {
      isReload:true,
      //1期限内，2期限外
      showType:1,
      dialogVisible:true,
      lineCodes:[],
      selectedKeys:[],
      stationCodes:[],
      conductorPersonNames:[],//售票员名称
      operationCodes:[],
      headers:{},
      formData:{
        dynamic: []
      },
      option:{
      },
      parentThis:null
    }
  },
  created() {
  },
  methods: {
    fenExYuangettoFixed,
    handleSubmit(auditSate){
      let th=this;
      let param={};
      param.fileUrl=this.formData.fileUrl;
      param.appealStatus=2;//已申诉
      param.auditSate=3;//3.售票员申诉
      param.appealType=this.showType; //1期限内，2期限外
      //正常申诉必填
      if(this.showType == '1'){
        if(this.formData.appealReason == null || this.formData.appealReason == '' || this.formData.appealReason == undefined){
          this.$message.info('请输入车站申诉原因！')
          return false;
        }
        param.appealReason=this.formData.appealReason;
      }
      //超期申诉必填
      if(this.showType == '2'){
        if(this.formData.overtimeReason == null || this.formData.overtimeReason == '' || this.formData.overtimeReason == undefined){
          this.$message.info('请输入超期申诉原因！')
          return false;
        }
        param.overtimeReason=this.formData.overtimeReason;
      }
      param.remark=this.formData.remark;
      param.id=this.formData.id;
      updateSwAuTvmNotice(param).then(res=>{
        if(res.data.code==0){
          th.$message.success("操作成功！");
          th.closed();
          th.parentThis.getList();
        }else{
          th.$message.error("操作失败！");
        }
      }).catch((e)=>{
        th.$message.error("操作失败！");
      });
    },
    recallShow(row,showType,parentThis){
      this.parentThis=parentThis;
      this.showType=showType;
      this.getOption();
      this.formData=row;
    },
    closed(){
      this.dialogVisible=false;
      this.$parent.dialogVisibleAppealReply=false;
    },
    getOption(){
      let th=this;
      this.option=this.getAddOption(th);
      this.isReload=false;
      this.$nextTick(()=>{
        this.isReload=true;
      })
    },
    uploadSuccess(response, file, fileList){
      this.formData.fileUrl=file.name;
      this.list=response.data;
      this.dialogVisible=true;
      this.getOption();
      console.log(response, file, fileList)
    },
    getAuth(){
      const token = this.$store.getters.access_token;
      if (token) {
        this.headers['Authorization'] = 'Bearer ' + token// token
      }
    },
    getAddOption(th) {
      return {
        submitBtn:false,
        emptyBtn:false,
        group:[
          {
            icon:'',
            label: '',
            // collapse:false,
            prop: 'group1',
            column: [{
              label: '售票员',
              prop: 'conductorPersonName',
              labelWidth:130,
              // formslot:true,
              type:'select'
            },{
              label: '售票员工号',
              prop: 'conductorPersonCode',
              labelWidth:130,
              // formslot:true,
              type:'select'
            },{
              label: '收入日期',
              prop: 'recordTime',
              // width:'250',
              labelWidth:130,
              type:"yyyy-MM-dd"
              // formslot:true,
            },{
              label: '车站申诉原因',
              prop: 'appealReason',
              autoHeight: true,
              // width:'250',
              labelWidth:130,
              type:'textarea',
              display:this.showType==1,
            },
              // {
              //   label: '附件',
              //   prop: 'fujian',
              //   labelWidth:130,
              //   formslot:true,
              // },
              {
                label: "上传附件",
                prop: "fileUrl",
                type: "upload",
                labelWidth:130,
                component: "zd-upload",
                dataType: "string",
                display:false
              },
              {
                label: '超期申诉原因',
                prop: 'overtimeReason',
                // width:'250',
                labelWidth:130,
                type:'textarea',
                display:this.showType==2,
                rules: [
                  { required: true, trigger: 'blur', message: '请输入超期申诉原因' },
                ]
              },{
                label: '车站备注',
                prop: 'remark',
                // width:'250',
                labelWidth:130,
                type:'textarea',
              }]
          },
        ]
      };
    }
  },
  mounted() {
    this.getAuth();
  }
}
</script>
<style lang="scss">
.huLianWangShouPiaojiDataInput.EditorOrAdd{
  .avue-group[index='2']{
    .avue-form__group{
      .avue-form__row{
        width: 100%;
      }
    }
  }
  @media only screen and (min-width: 992px){
    width: 100%;
  }
  .avue-crud__tip{
    display: none;
  }
}
.zhanNeiRYDLCK {
  .upload-fujian{
    display: inline-flex;
    .el-upload-list {
      display: none;
    }
  }

}
</style>
